home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / prime_tests / primes.amos / primes.amosSourceCode
AMOS Source Code  |  1999-07-24  |  614b  |  17 lines

  1. ' This program finds the prime-numbers from 2 to 3000 by a simplistic
  2. ' method. It was originally written as a test of the Cursor compiler 
  3. ' where the compiled program needs 12 seconds to find the first 1000 
  4. ' primes; with AmigaBASIC it takes about 139 seconds on an Amiga 500 
  5. ' This is essentially just a test of overheads plus MOD, FOR and IF.   
  6. '
  7.  Print "Searching for prime numbers from 2 to 3000:"
  8.  BEGINTIME=Timer
  9.  For A=2 To 3000
  10.    For B=3 To A-1
  11.      If A mod B=0 Then Goto HOPOUT
  12.    Next B
  13.    Rem PRINT a
  14. HOPOUT:
  15.  Next A
  16.  Print "time needed:"+Str$((Timer-BEGINTIME)*20)+" mS."
  17.  While Inkey$="" : Wend